All files / Bandstand/src/app/brand/[id]/icon.png route.ts

0% Statements 0/21
0% Branches 0/1
0% Functions 0/1
0% Lines 0/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22                                           
export const dynamic = 'force-dynamic'

import {prisma} from '@/lib/db'

/**
 * A band's home-screen icon. Public: the phone fetches it before anyone
 * signs in (and it is a logo, not band business). Versioned by ?v=, so it
 * caches for good.
 */
export const GET = async (req: Request, {params}: {params: {id: string}}) => {
  const icon = await prisma.bandIcon.findUnique({where: {bandId: params.id}})
  if (!icon)
    return Response.redirect(new URL('/icons/default-512.png', req.url), 307)
  return new Response(new Uint8Array(icon.data), {
    headers: {
      'Content-Type': icon.mime,
      'Cache-Control': 'public, max-age=31536000, immutable',
      'X-Content-Type-Options': 'nosniff',
    },
  })
}